ab2410
@@ -42,14 +42,12 @@
import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.MediaType;
 import org.springframework.http.client.reactive.ClientHttpRequest;
-import org.springframework.http.client.reactive.ClientHttpResponse;
 import org.springframework.lang.Nullable;
 import org.springframework.util.Assert;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.LinkedMultiValueMap;
 import org.springframework.util.MimeType;
 import org.springframework.util.MultiValueMap;
-import org.springframework.web.reactive.function.BodyExtractor;
 import org.springframework.web.reactive.function.BodyExtractors;
 import org.springframework.web.reactive.function.BodyInserter;
 import org.springframework.web.reactive.function.BodyInserters;
@@ -405,8 +403,9 @@
class DefaultWebClient implements WebClient {
 		@Override
 		@SuppressWarnings("unchecked")
 		public <T> Mono<T> bodyToMono(Class<T> bodyType) {
+			// Use bodyToMono (vs BodyExtractors) to ensure proper handling of Void.class...
 			return this.responseMono.flatMap(
-					response -> bodyToPublisher(response, BodyExtractors.toMono(bodyType),
+					response -> bodyToPublisher(response, response.bodyToMono(bodyType),
 							this::monoThrowableToMono));
 		}
 
@@ -414,7 +413,7 @@
class DefaultWebClient implements WebClient {
 		@SuppressWarnings("unchecked")
 		public <T> Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference) {
 			return this.responseMono.flatMap(
-					response -> bodyToPublisher(response, BodyExtractors.toMono(typeReference),
+					response -> bodyToPublisher(response, response.bodyToMono(typeReference),
 							this::monoThrowableToMono));
 		}
 
@@ -425,14 +424,14 @@
class DefaultWebClient implements WebClient {
 		@Override
 		public <T> Flux<T> bodyToFlux(Class<T> elementType) {
 			return this.responseMono.flatMapMany(
-					response -> bodyToPublisher(response, BodyExtractors.toFlux(elementType),
+					response -> bodyToPublisher(response, response.bodyToFlux(elementType),
 							this::monoThrowableToFlux));
 		}
 
 		@Override
 		public <T> Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference) {
 			return this.responseMono.flatMapMany(
-					response -> bodyToPublisher(response, BodyExtractors.toFlux(typeReference),
+					response -> bodyToPublisher(response, response.bodyToFlux(typeReference),
 							this::monoThrowableToFlux));
 		}
 
@@ -441,15 +440,14 @@
class DefaultWebClient implements WebClient {
 		}
 
 		private <T extends Publisher<?>> T bodyToPublisher(ClientResponse response,
-				BodyExtractor<T, ? super ClientHttpResponse> extractor,
-				Function<Mono<? extends Throwable>, T> errorFunction) {
+				T bodyPublisher, Function<Mono<? extends Throwable>, T> errorFunction) {
 
 			return this.statusHandlers.stream()
 					.filter(statusHandler -> statusHandler.test(response.statusCode()))
 					.findFirst()
 					.map(statusHandler -> statusHandler.apply(response))
 					.map(errorFunction::apply)
-					.orElse(response.body(extractor));
+					.orElse(bodyPublisher);
 		}
 
 		private static Mono<WebClientResponseException> createResponseException(ClientResponse response) {
